﻿using BussinessObject.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectHK3.App_Code;

namespace ProjectHK3.Object_One
{
    public partial class Service : System.Web.UI.Page
    {
        B_LoadGidAD ex = new B_LoadGidAD();
        DataTable tb = new DataTable();
        B_Delete mn = new B_Delete();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                tb = ex.loadSer();
                Label3.Text = tb.Rows.Count.ToString();
                GridView1.DataSource = tb;
                GridView1.DataBind();

            }
        }

        protected void _lbtRemove_Command(object sender, CommandEventArgs e)
        {

            if (e.CommandName == "Delete")
            {


                Session["Sevice"] = Convert.ToInt32(e.CommandArgument.ToString());
                if (mn.DeleteService(Convert.ToInt32(Session["Sevice"].ToString())) == true)
                {
                    Alert.Show("Delete Successful.");
                }
                else
                {
                    Alert.Show("You can't delete.Because it is being used. ");
                }

            }
        }

        protected void _lbtViewDetails_Command(object sender, CommandEventArgs e)
        {
            Session["Sevice"] = Convert.ToInt32(e.CommandArgument.ToString());
            Response.Redirect("../Object One/ServiceDetail.aspx");
        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (mn.DeleteService(Convert.ToInt32(Session["Sevice"].ToString())) == true)
            {
                Alert.Show("Delete Successful");
            }
            else
            {
                Alert.Show("you can not delete because it is being used ");
            }
        }
    }
}